Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cop to stop bin use in service blocks #15154

Conversation

apainintheneck
Copy link
Contributor

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

Fixes #15113. The offending formulas were already changed in Homebrew/homebrew-core#127462. This just stops people from using it in the future here. The preferred method is opt_bin because that works with the API and is more portable (works between versions).

There was some talk about making this a runtime error but I opted for a cop because a runtime error wouldn't be backwards compatible. We can check and change everything in homebrew/core but we can't do that for private taps.

I also removed the last example from the docs of bin/"name" from the service block section.

The preferred method is opt_bin because that works
with the API and is more portable (works between versions).

Also removed the last example from the docs of `bin/"name"`
from the service block section
@apainintheneck apainintheneck self-assigned this Apr 5, 2023
@apainintheneck
Copy link
Contributor Author

The changes on core were already fixed as mentioned above but this is what the error would look like before those changes.

Offenses:

Library/Taps/homebrew/homebrew-core/Formula/apache-pulsar.rb:60:10: C: [Correctable] Use opt_bin instead of bin in service blocks.
    run [bin/"pulsar", "standalone"]
         ^^^
Library/Taps/homebrew/homebrew-core/Formula/influxdb.rb:103:9: C: [Correctable] Use opt_bin instead of bin in service blocks.
    run bin/"influxd"
        ^^^
Library/Taps/homebrew/homebrew-core/Formula/languagetool.rb:50:10: C: [Correctable] Use opt_bin instead of bin in service blocks.
    run [bin/"languagetool-server", "--port", "8081", "--allow-origin"]
         ^^^
Library/Taps/homebrew/homebrew-core/Formula/nsq.rb:35:10: C: [Correctable] Use opt_bin instead of bin in service blocks.
    run [bin/"nsqd", "-data-path=#{var}/nsq"]
         ^^^
Library/Taps/homebrew/homebrew-core/Formula/sftpgo.rb:56:10: C: [Correctable] Use opt_bin instead of bin in service blocks.
    run [bin/"sftpgo", "serve", "--config-file", etc/"sftpgo/sftpgo.json", "--log-file-path",
         ^^^
Library/Taps/homebrew/homebrew-core/Formula/trojan-go.rb:73:10: C: [Correctable] Use opt_bin instead of bin in service blocks.
    run [bin/"trojan-go", "-config", etc/"trojan-go/config.json"]
         ^^^
Library/Taps/homebrew/homebrew-core/Formula/v2ray.rb:64:10: C: [Correctable] Use opt_bin instead of bin in service blocks.
    run [bin/"v2ray", "run", "-config", etc/"v2ray/config.json"]
         ^^^
Library/Taps/homebrew/homebrew-core/Formula/vlmcsd.rb:59:10: C: [Correctable] Use opt_bin instead of bin in service blocks.
    run [bin/"vlmcsd", "-i", etc/"vlmcsd/vlmcsd.ini", "-D"]
         ^^^

6618 files inspected, 8 offenses detected, 8 offenses autocorrectable

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again @apainintheneck, great work!

@MikeMcQuaid MikeMcQuaid merged commit 3404767 into Homebrew:master Apr 5, 2023
24 checks passed
ZhongRuoyu added a commit to ZhongRuoyu/brew that referenced this pull request Apr 29, 2023
This is a follow-up to Homebrew#15154. In addition to `bin`, the `service` block
can also reference other cellar paths like `libexec`. They don't work
with the API either, as reported in
https://github.com/orgs/Homebrew/discussions/4459.

Violations are already corrected in Homebrew/homebrew-core#129736.

Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com>
ZhongRuoyu added a commit to ZhongRuoyu/brew that referenced this pull request Apr 29, 2023
This is a follow-up to Homebrew#15154. In addition to `bin`, the `service` block
can also reference other cellar paths like `libexec`. They don't work
with the API either, as reported in
https://github.com/orgs/Homebrew/discussions/4459.

Violations are already corrected in Homebrew/homebrew-core#129736
and Homebrew/homebrew-core#129737.

Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com>
ZhongRuoyu added a commit to ZhongRuoyu/brew that referenced this pull request Apr 29, 2023
This is a follow-up to Homebrew#15154. In addition to `bin`, the `service` block
can also reference other cellar paths like `libexec`. They don't work
with the API either, as reported in
https://github.com/orgs/Homebrew/discussions/4459.

Violations are already corrected in Homebrew/homebrew-core#129736
and Homebrew/homebrew-core#129737.

Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com>
@github-actions github-actions bot added the outdated PR was locked due to age label May 6, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2023
@apainintheneck apainintheneck deleted the cop-to-prevent-bin-in-service-blocks branch May 14, 2023 19:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bin/ directory location uses wrong HOMEBREW_PREFIX in M1
2 participants